//
// Device.cs
//
// Copyright (C) 2008 Lukas Lipka <lukaslipka@gmail.com>
//
 
using System;
using System.Collections;

using NDesk.DBus;

namespace NetworkManager {

	public enum DeviceType : uint {
		Unknown,
		Wired,
		Wireless
	}
    
	public class Device {

		private static readonly string INTERFACE_NAME = "org.freedesktop.NetworkManager";

		private IDevice device = null;
        
		internal Device (ObjectPath path)
		{
			Bus bus = Bus.System;
			this.device = bus.GetObject<IDevice> (INTERFACE_NAME, path);
		}
        
		public override string ToString()
		{
			System.Text.StringBuilder builder = new System.Text.StringBuilder ();
			builder.Append ("Udi: " + Udi + "\n");
			builder.Append ("Type: " + DeviceType + "\n");
			builder.Append ("IP4 Address: " + IP4Address + "\n");
			
			return builder.ToString ();
		}
             
		public string Udi {
			get { return device.Udi; }
		}

		public string Interface {
			get { return device.Interface; }
		}
        
		public DeviceType DeviceType {
			get { return device.DeviceType; }
                }

		public System.Net.IPAddress IP4Address {
			get { return new System.Net.IPAddress (device.Ip4Address); }
		}
	}
}
